package work20241226;

import java.sql.SQLOutput;
import java.util.concurrent.*;

/**
 * @author zdl
 * @date 2024/12/26
 */
public class Demo16 {
    public static void main(String[] args) {
        //16. 创建一个定长线程池，包含3个线程。提交5个任务到线程池，每个任务打印当前线程的名称。
        /*ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(3, 6, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(2));
        for (int i = 0; i < 5; i++) {
            poolExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"线程:");
                }
            });
        }*/
        ExecutorService pool = Executors.newFixedThreadPool(3);
        for (int i = 0; i < 5; i++) {
            pool.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"线程:");
                }
            });
        }

    }
}
